package cyx.example.ddd.application.order.command;

import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Currency;
import java.util.List;

/**
 * 创建订单命令
 */
@Data
public class CreateOrderCommand {
    @NotNull(message = "用户ID不能为空")
    private String userId;

    @NotNull(message = "货币类型不能为空")
    private Currency currency;

    @NotEmpty(message = "订单项不能为空")
    @Valid
    private List<OrderItemCommand> items;

    @Data
    public static class OrderItemCommand {
        @NotNull(message = "商品ID不能为空")
        private String productId;

        @NotNull(message = "商品名称不能为空")
        private String productName;

        @NotNull(message = "商品单价不能为空")
        private Double unitPrice;

        @NotNull(message = "商品数量不能为空")
        private Integer quantity;
    }
}